package com.tidc.seaservermodel.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * (Email)实体类
 *
 * @author makejava
 * @since 2020-09-25 16:17:00
 */
@Data
@Accessors(chain = true) //这个注解可以使这个类的set方法返回当前对象
@NoArgsConstructor
public class Email implements Serializable {
    private static final long serialVersionUID = 180042241719033190L;
    
    private Integer id;
    
    private String sender;
    /**
    * 标题
    */
    private String caption;
    /**
    * 内容
    */
    private String content;
    private Timestamp createTime;
    
    private Integer isDelete;

    private Integer recipientId;
    public static Email systemAccomplishTaskEmail(String caption,String Content,Integer recipientId){
        Email email = new Email();
        email.setSender("系统");
        email.setCaption(caption);
        email.setContent(Content);
        email.setRecipientId(recipientId);
        return email;
    }

    /**
     * 二级用户兑换奖励发送信息通知一级
     * @param username
     * @param amount
     * @param shopName
     * @param recipientId
     * @return
     */
    public static Email secondaryBuyShopEmail(String username,int amount,String shopName,int recipientId){
        Email email = new Email();
        email.setSender("系统");
        email.setCaption(username+"兑换了奖励");
        email.setContent(username+"兑换了"+amount+"个"+shopName);
        email.setRecipientId(recipientId);
        return email;
    }

    /**
     * 给supervisor发送短信告知某下级账号使用了奖励
     * @param username
     * @param amount
     * @param shopName
     * @param recipientId
     * @return
     */
    public static Email secondaryUseShop(String username,int amount,String shopName,int recipientId){
        Email email = new Email();
        email.setSender("系统");
        email.setCaption(username+"使用了一个奖励");
        email.setContent(username+"使用了"+amount+"个"+shopName+"请及时兑现");
        email.setRecipientId(recipientId);
        return email;
    }

    /**
     * 告知下级账号 主账号已完成了奖励的兑现
     * @param commitment
     * @return
     */
    public static Email supervisorFulfillCommitment(Commitment commitment){
        Email email = new Email();
        email.setSender("系统");
        email.setCaption("您的上级用户兑现了一个奖励");
        email.setContent("您的上级用户兑现了奖励"+commitment.getShopName());
        email.setRecipientId(commitment.getAskUserId());
        return email;
    }
    public static Email sendSupervisorTaskOverdue(String secondaryName,String taskName,Integer supervisorId){
        return Email.systemAccomplishTaskEmail(secondaryName+ "任务超时",
                secondaryName + "的" + taskName + "任务超时了", supervisorId);
    }
    public static Email sendSecondaryTaskOverdue(String taskName,int userId){
        return Email.systemAccomplishTaskEmail("您的任务已超时","您的任务" + taskName + "已超时",userId);
    }
}